import { ResPage, Good } from "@/api/interface/index";
import { GOOD, PROCUREDCENTER } from "@/api/config/servicePort";
import http from "@/api";

// 获取商品列表
export const getGoodsTreeEntity = (params: Good.ReqGoodsEntity) => {
  return http.post<ResPage<Good.ReqGoodsEntity>>(PROCUREDCENTER + `/goods/page`, params);
};

// 获取商品分类侧边栏列表
export const getGoodsListTree = () => {
  return http.get<Good.ReqGoodsTreeList[]>(PROCUREDCENTER + `/goodsList/tree`);
};

// 获取一级分类
export const getGoodsList = () => {
  return http.get<Good.ReqGoodsList[]>(PROCUREDCENTER + `/goodsList/list`);
};

// 获取二级分类
export const getGoodsSet = (params: { listId: number }) => {
  return http.get<Good.ReqGoodsSet[]>(PROCUREDCENTER + `/goodsSet/listByList`, params);
};

// 通过二级分类获取一级分类名称
export const getClassifyBySetId = (params: { setId: number }) => {
  return http.get<Good.ReqClassify>(PROCUREDCENTER + `/goodsList/getClassifyBySetId`, params);
};

// 新增商品
export const addGoodsEntity = (params: any) => {
  return http.post(PROCUREDCENTER + `/goods/create`, params);
};

// 新增一级分类
export const addGoodsList = (params: any) => {
  return http.post(PROCUREDCENTER + `/goodsList/create`, params);
};

// 新增二级分类
export const addGoodsSet = (params: any) => {
  return http.post(PROCUREDCENTER + `/goodsSet/create`, params);
};

// 批量添加商品
export const BatchAddGoods = (params: FormData) => {
  return http.post(GOOD + `/good/import`, params);
};

// 编辑商品
export const editGoods = (params: any) => {
  return http.post(PROCUREDCENTER + `/goods/update`, params);
};

// 删除商品
export const deleteGoods = (params: { goodsId: string[] }) => {
  return http.post(GOOD + `/good/delete`, params);
};
